home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10603 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Pointers to register
  5. Date: 18 Mar 1996 21:49:42 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4iklpm$28s@sparcserver.lrz-muenchen.de>
  9. References: <1239@altheim.win-uk.net>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. broldham@altheim.win-uk.net (Brian R. Oldham) writes:
  13.  
  14. >A couple of weeks ago someone posted the opinion that all objects in
  15. >memory must have an address, which might have gone uncontested but for
  16. >the fact that he added that therefore all pointers must point to an
  17. >address. Someone else reminded us that registers don't have an address.
  18.  
  19. >Bearing in mind the usual way to assign a pointer:
  20.  
  21. >    ptr = &var;
  22.  
  23. >is correct for objects in memory, but how do you assign a pointer
  24. >to a register? 
  25.  
  26. >The following function (a getch() for x86) works: But is it right??
  27. >    
  28. >/* Read next keystroke */
  29. >#include <dos.h>
  30.  
  31. >#define KEYBD 0x16
  32.  
  33. >static union REGS inregs, outregs;
  34.  
  35. >void getkey(int *scancode, char *ch) 
  36. >{
  37. >    inregs.h.ah = 0x00;
  38. >    int86(KEYBD,&inregs,&outregs);
  39.  
  40. You use two structs that are members of a union to communicate with 
  41. a function that knows how to deal with them. This does not mean that 
  42. you are "taking the address of a register".  
  43.  
  44. "inregs" and "outregs" are variables in your program. Try:
  45.  
  46.    {
  47.       union REGS foo, bar, baz, bam;
  48.    }
  49.  
  50. Those variables are in no way related to any registers.
  51.  
  52. Kurt
  53. --
  54. | Kurt Watzka                             Phone : +49-89-2180-6254
  55. | watzka@stat.uni-muenchen.de
  56. | ua302aa@sunmail.lrz-muenchen.de
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.